<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        
    </style>
</head>

<body>
    <button>按钮</button>
    <p>eeee</p>
    <div class="inner"></div>
    <div class="create"></div>
    <script>
     // window.onload = function() {
       // document.write('<div>123</div>')
    // }
     // 三种创建元素的方式
     // 1. document.write() 创建元素 如果页面文档加载完毕，再调用的话会导致页面重绘
     var btn = document.querySelector('button');
     btn.onclick = function() {
        document.write('<div>123</div>')
     }

     //2.innerHTML 创建元素
     var inner = document.querySelector('.inner');
     inner.innerHTML = '<a href="#">百度</a>';
     //3.document.createElement() 创建元素
     var create = document.querySelector('.create');
     var a = document.createElement('a');
     create.appendChild(a);
    </script>
</body>

</html>